<?php
/* 
 * ebiz front
 * 
 * Customer Model
 * 
 * @author fusq
 * 
 */
require_once '../app/core/models/BaseDao.php';
require_once '../app/core/db/DBUtil.class.php';

class SpecialProductItemDao extends BaseDao {

    private $tableName = 'special_product_items';

    public function __construct($dbUtil){
        parent::__construct($dbUtil);
        $this->_name = $this->tableName;
    }
    
    public function getProductItemsByType($type){
    	$sql = "select pi.*,p.title,p.url_title,pimage.name as iname,pimage.folder as ifolder from product_items pi 
    	        left outer join products p on p.id = pi.product_id 
    	        left outer join product_images pimage on pi.id = pimage.item_id and pimage.is_delete = 0 and pimage.default_item_image = 1  
    	        left outer join special_product_items spi on spi.product_item_id = pi.id and spi.is_delete = 0 
    	        where spi.special_type = ? and pi.is_delete = 0 group by pi.id order by spi.id asc";
    	$parms = array($type);
    	return $this->dbUtil->SelectData($sql,$parms);
    }
}